
#ifndef _RESAMPLE_H
#define _RESAMPLE_H


#define MONO			1
#define STEREO			2

#define CHANNEL_LEFT	0
#define CHANNEL_RIGHT	1
#define CHANNEL_MEAN	2

/*
 * Function:
 *          ResampleWav && ResampleBuf
 * Description:
 *          Resample with anti-alias filter and anti-image filter. 
 * Features:
 *			1. Resample scheme is carefully designed to avoid time excursion.
 *			2. High order lowpass filter and Kaiser-Window(Beta=10.0) are used to 
 *			   provide excellent quality.
 *			3. Input wave can be either mono or 2chan stereo.			
 *			4. Polyphase decomposition technique is used to accelerate computing.  
 *			5. Intel(R) Performance Primitives is used to achieve best performance.  
 *			   (Optional. Define USE_IPPS in workplace to enable IPP)
 *			6. Quite small amount of memory is needed.(usually about 2M)
 * Arguments:
 *          src: source buffer
 *          dst: destination buffer
 *          srclen: length of src
 *          Ufactor: upsample factor
 *			Dfactor: downsample factor
 *          WavIn: path of input wav file
 *          WavOut: path of output wav file
 *			OutSampleRate: output sample rate
 *			srcChannel: channel of source buffer,must be MONO(1) or STEREO(2)
 *			ChannelMode: Only meaningful for stereo wav. Default: CHANNEL_LEFT
 *					CHANNEL_LEFT: always use the left channel
 *					CHANNEL_RIGHT: always use the right channel
 *					CHANNEL_MEAN: always use the mean of the left and the right
 * Return:
 *			ResampleBuf:
 *				>0 : count of output samples(dst), that is, OutBytes/sizeof(short)
 *				=0 : any error take place
 *			ResampleWav:
 *				=1 : no error
 *				=0 : any error take palce
 * Notice:
 *			1. The output wav(buf) is mono!
 *			2. The input wav must be 16bit-(mono|2ChanStereo)-linearPCM encoding!
 *			3. ResampleBuf src is assumed to be 16bit-linerPCM 2bytestream!
 *			4. Intel(R) compiler is recommended.
 *			5. IPPS resource should be accessible when defining USE_IPPS.
 *			6. When using ResampleBuf, the caller should guarantee that the dst buffer length 
 *		       is large enough.
 * Author:
 *          Xiao Wu
 * Date:  
 *			2005/04/26
 * Modified:
 *			2005/05/03
 *			2005/05/19
*/
size_t ResampleWav(const char* WavIn, const char* WavOut, int OutSampleRate, int ChannelMode = CHANNEL_LEFT);

size_t ResampleBuf(const short* src, short* dst, size_t srclen, int Ufactor, int Dfactor, int srcChannel);

#endif